import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * @Author：徐志荣
 * @Date：2023/5/22 10:26
 */
//定位一组元素
public class Test5 {
    public static void main(String[] args) {
        WebDriver webDriver = new ChromeDriver();
        //搜索 咱们的html
        webDriver.get("http://localhost:63342/_20230512_TestCode/src/main/html/test01.html?_ijt=n5oqjo19i547t4fmjoc8pkoglq&_ij_reload=RELOAD_ON_SAVE");
       //隐式等待
        webDriver.manage().timeouts().implicitlyWait(3,TimeUnit.DAYS);
        List<WebElement> webDriverElements = webDriver.findElements(By.cssSelector("input"));
        for (int i = 0; i < webDriverElements.size(); i++) {
            //如果每个元素type = checkbox 进行点击
            //否则什么也不操作
            //getAttribute :获取页面上的元素属性值
            String type = webDriverElements.get(i).getAttribute("type");
            if(type.equals("checkout")){
                webDriverElements.get(i).click();
            }else {
                //什么也不操作
            }
        }
    }
}
